gdbsx: malloc extra bye for null char
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 19 Oct 2009 09:49:23 +0000 (10:49 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 19 Oct 2009 09:49:23 +0000 (10:49 +0100)
Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
tools/debugger/gdbsx/gx/gx_comm.c
tools/debugger/gdbsx/gx/gx_main.c

index f991952239fb6c10dc42b74625d2d422a589904d..156a9f5f5532574bc654c4239754ec5984fdd610 100644 (file)
@@ -299,6 +299,7 @@ gx_putpkt (char *buf)
 
         if (write(remote_fd, buf2, p - buf2) != p - buf2) {
             perror("putpkt(write)");
+            free(buf2);
             return -1;
         }
         if (gx_remote_dbg)
index f20f6ef0d72e655241ed477bcf2dd864ed469974..07923af973e7869b15895d23f77ba701a66f7973 100644 (file)
@@ -201,7 +201,7 @@ process_m_request(char *remote_buf)
 
     gx_decode_m_packet(&remote_buf[1], &addr, &len);
 
-    if ((xbuf=malloc(len)) == NULL) {
+    if ((xbuf=malloc(len+1)) == NULL) {
         gx_reply_error(remote_buf);
         return;
     }
@@ -227,7 +227,7 @@ process_M_request(char *remote_buf)
 
     data_strtp = gx_decode_M_packet(&remote_buf[1], &addr, &len);
 
-    if ((xbuf=malloc(len)) == NULL) {
+    if ((xbuf=malloc(len+1)) == NULL) {
         gx_reply_error(remote_buf);
         return;
     }